package com.siqi.hr.system.custom.utils;

import com.siqi.hr.system.common.model.ModuleType;
import com.siqi.hr.system.common.utils.EnumUtils;

import java.util.Collection;

/**
 * 处理实体工具类
 * @author     xiaogq
 * Created by xiaogoingqin on 2016/8/9
 */
public class EntityUtils {

    /**
     * 处理实体属于那些模块方法(xiaogq)
     * @param loginModule        所属模块数字字符串
     * @return
     */
    public static String tranformLoginModule(String loginModule) {
        Collection<ModuleType> modules = EnumUtils.tranform(loginModule, ModuleType.class);
        StringBuilder modulesStr = new StringBuilder();
        if (modules.size() > 0) {
            for (ModuleType mod : modules) {
                String modDesc = mod.getDesc();
                if ((modDesc != null) && (!modDesc.equals("")))
                    modulesStr.append(mod.getDesc() + ",");
            }
        }
        if (!modulesStr.toString().equals(""))
            modulesStr.deleteCharAt(modulesStr.lastIndexOf(","));
        return modulesStr.toString();
    }

}
